feat(profiles): carry codex_config through to the Codex runtime config.toml - #145
Merged
Conversation
…g.toml cue launch codex repoints CODEX_HOME at the materialized runtime, whose config.toml was rendered from MCP servers only. Every other key a user had in ~/.codex/config.toml was dropped, with no warning and no profile field to carry it -- so sandbox_mode, sandbox_workspace_write, approval_policy and shell_environment_policy were unreachable under cue. Found while driving ego-browser from codex: it needs a writable Chromium profile dir outside the workspace. Setting sandbox_workspace_write in ~/.codex/config.toml did nothing; the same values as -c overrides worked. The failure is silent -- codex starts fine and the setting has no effect. Adds an optional codex_config map to profile.yaml, merged into the rendered config.toml next to mcp_servers. Emitted verbatim as TOML, ignored for non-Codex agents. Two details worth flagging: - Ordering. Bare keys are emitted before any [table] header. TOML binds every key after a header to that table, so sandbox_mode written after [mcp_servers.foo] would silently become mcp_servers.foo.sandbox_mode. - Merge depth. Two levels, not one. Unlike env's flat strings this is tables, and selectors here run 10+ profiles wide; a shallow merge would let a profile setting only sandbox_workspace_write.network_access delete a sibling's writable_roots. That is the same silent-drop class of bug this change exists to fix. Refs #144 Tests: 5 added (ordering, real TOML parse, empty-config shape, two-level composite merge, leaf collision). Full suite failing set is byte-identical to origin/main (34 pre-existing failures on both, zero new).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #144.
Problem
cue launch codexrepointsCODEX_HOMEat the materialized runtime, and thatconfig.tomlwas rendered from MCP servers only:Everything else a user had in
~/.codex/config.tomlwas dropped, with no warning and no profile field to carry it.sandbox_mode,sandbox_workspace_write,approval_policy,shell_environment_policywere all unreachable under cue.It fails silently — codex starts fine, the setting just has no effect.
Repro that found it
Driving
ego-browserfrom codex. It launches Chromium against a persistent profile outside the workspace, so it needs those roots writable:Identical values passed as
-coverrides instead of via config:H1=Example Domain.Change
Optional
codex_configmap in profile.yaml, merged into the renderedconfig.tomlbesidemcp_servers. Verbatim TOML, ignored for non-Codex agents.Two decisions worth review:
Ordering. Bare keys emit before any
[table]header. TOML binds every key after a header to that table, sosandbox_modewritten after[mcp_servers.foo]would silently becomemcp_servers.foo.sandbox_mode. Directly asserted in a test.Merge depth — two levels, not one.
envis flat strings so shallow is right; this is tables, and selectors here run 10+ profiles wide. A shallow merge would let a profile setting onlysandbox_workspace_write.network_accessdelete a sibling'swritable_roots— the same silent-drop class of bug this PR exists to fix. Deeper than two levels replaces wholesale, to keep the rule stateable.Test plan
Bun.TOML.parseround-trip (not substring matching), empty-config shape, two-level composite merge, leaf collisiontsc --noEmitcleanbiome lintclean on both changed source filesorigin/main, 34 failing here, failing set byte-identical (diffof sorted names is empty). Suite is red at baseline; this adds none. Pass count +5, exactly the new tests.Docs
profiles/SCHEMA.md— field row, a worked YAML→TOML example, the ordering rationale, and the merge-depth rule in the inheritance section.